<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no,minimal-ui">
<title>${site.name} - Powered by JavaCMS</title>
<link rel="stylesheet" type="text/css" href="/${mobileRes!}/css/index.css"> 
<script src="${resSys}/jquery.js" type="text/javascript"></script>
<script src="${resSys}/front.js" type="text/javascript"></script>

</head>

<body>
<div class="viewport">
  [#include "../include/header_message.html" /]
  <div class="message-top">
    <div style="display:inline-block; height:100%;">
      [#if user??]
      <div class="message-top-user">
        <div class="message-top-userImg">[#if user.userImg??]<img src="${user.userImg}">[#else]<img src="/${res}/images/userImg.png">[/#if]</div>
      </div>
      <div class="message-top-right">
        <div class="message-top-username">${user.username}</div>
      </div>
      [#else]
      <div class="message-top-user">
        <div class="message-top-userImg"><img src="/${res}/images/userImg.png"></div>
      </div>
      <div class="message-top-right" style="margin-left:40px;">
        <div class="message-top-username"><a href="${base}/login.jspx">登录</a>|<a href="${base}/register.jspx">注册</a></div>
      </div>
      [/#if]
    </div>
  </div>
  <form id="guestbookForm" action="${base}/guestbook.jspx" method="post">
  <div class="message-content">
    <div  class="message-content-ctg">
      <select name="ctgId">
      [@cms_guestbook_ctg_list siteId=site.id]
      [#list tag_list as ctg]
      <option value="${ctg.id}">${ctg.name}</option>
      [/#list]
      [/@cms_guestbook_ctg_list]
      </select>
    </div>
    <div class="message-content-title"><input type="text" name="title" placeholder="在此输入标题"></div>
    <div class="message-content-txt"><textarea name="content" cols="55" rows="4" placeholder="在此输入内容"></textarea></div>
    <div class="message-content-code clearfix">
      <div class="codecon"><input type="text" name="captcha" maxlength="20" vld="{required:true}" placeholder="在此输入验证码"></div>
      <i><img id="guestbookCaptcha" src="${base}/captcha.svl" onclick="this.src='${base}/captcha.svl?d='+new Date()"></i>
    </div>
    <div class="message-content-btn"><input type="hidden" name="sessionId" id="sessionId" /><input type="submit" id="submit" value="提 交"></div>
  </div>
  </form>                                           
            <script type="text/javascript">
            $(function() {
            	$("#sessionId").val($.cookie("JSESSIONID"));
	        	$("#submit").click(function () {
	                var options = {
	                    url: 'guestbook.jspx',
	                    type: 'post',
	                    dataType: 'json',
	                    data: $("#guestbookForm").serialize(),
	                    success:  function (data) {
		                	if(data.status==0) {
			                    alert("留言成功");
			                    location.href=location.href;
			                } else if(data.status==1) {	
			                    alert("验证码错误");
			                    $("#guestbookCaptcha").click();
			                }
	                    }
	                };
	                $.ajax(options);
	                return false;
	            });
            });
            
            </script>
</div>
</body>
</html>